package info.nightbrest.agt.client.view.impl;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject;
import info.nightbrest.agt.client.Agt;
import info.nightbrest.agt.client.view.AgtShell;
import info.nightbrest.agt.client.view.LoginPanelView;

/**
 * UI shell for Agt sample app.
 */
public class AgtShellImpl extends Composite implements AgtShell
{
	interface AgtShellImplUiBinder extends UiBinder<Widget, AgtShellImpl>
	{
	}

	private static final AgtShellImplUiBinder binder = GWT.create(AgtShellImplUiBinder.class);

	private Presenter presenter;

	@UiField(provided = true)
	LoginPanelView loginPanel;
	@UiField
	SimplePanel searchWidget;
	@UiField
	SimplePanel contentPanel;
	@UiField
	Image       logotypeImage;

	@Inject
	public AgtShellImpl(LoginPanelView loginPanel)
	{
		this.loginPanel = loginPanel;

		initWidget(binder.createAndBindUi(this));

		loginPanel.setCollapsible();
		logotypeImage.setResource(Agt.images.AgtLogo());
	}

	@Override
	public LoginPanelView getLoginPanel()
	{
		return loginPanel;
	}

	@Override
	public void setPresenter(Presenter presenter)
	{
		this.presenter = presenter;
		loginPanel.setPresenter((LoginPanelView.Presenter) this.presenter);
	}

	@Override
	public AcceptsOneWidget getContentPanel()
	{
		return contentPanel;
	}
}